<?php

namespace app\model\referral;

use app\BaseModel;
use app\model\UserModel;
use think\model\relation\BelongsTo;

/**
 * 转介-记录
 */
class ReferralLogModel extends BaseModel
{
    protected $name = 'referral_log';

    /**
     * 用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind([
            'user_name' => 'name',
            'user_avatar' => 'avatar',
            'age',
            'sex',
            'username',
            'user_number',
            'student_status',
            'department_id',
            'unit_name',
            'id_card',
            'address',
            'birthday',
            'nation',
            'phone'
        ]);
    }

    /**
     * 机构
     * @return BelongsTo
     */
    public function agency(): BelongsTo
    {
        return $this->belongsTo(ReferralAgencyModel::class,'agency_id')->bind([
            'agency_name' => 'name',
        ]);
    }
}